package org.example.course.observer;

import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

// CourseAssignmentObservable.java
@Component
public class CourseAssignmentObservable {
    private final List<InboxObserver> observers = new ArrayList<>();

    public void addObserver(InboxObserver observer) {
        observers.add(observer);
    }

    public void notifyObservers(Long courseId, String name, Long objectId, Integer type,
                                LocalDateTime createTime, LocalDateTime endTime) {
        observers.forEach(obs ->
                obs.update(courseId, name, objectId, type, createTime, endTime));
    }
}